import java.lang.reflect.Array;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-10-18
 * Time:13:36
 */
class MyArray3<T>{
    public T[] array;
    /**
     * 通过反射创建，指定类型的数组
     * clazz:指定类型
     * capacity:指定容量
     */
   public MyArray3(Class<T> clazz,int capacity){
       array=(T[])Array.newInstance(clazz,capacity);
   }
    public T getPos(int pos){
        return this.array[pos];
    }
    public void setVal(int pos,T val){
        this.array[pos]=val;
    }
    public T[] getArray(){
        return array;
    }
}
public class TestDemo3 {
    public static void main(String[] args) {
        MyArray3<Integer> myArray=new MyArray3<>(Integer.class,10);
       Integer[] integers=myArray.getArray();

    }
}
